package anything;

/*XML - Well-Formed-ness*/
import java.io.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import org.xml.sax.*;

public class DOMParserCheck {
  static public void main(String[] arg){
    try{
      //BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
      //System.out.print("Enter File name: ");
      //String xmlFile = bf.readLine();
      File file = new File("res/test/Employee-Detail.xml");
      if(file.exists()) {
        try {
          // Create a new factory to create parsers 
          DocumentBuilderFactory dBF = DocumentBuilderFactory.newInstance();
          // Use the factory to create a parser (builder) and use
          // it to parse the document.
          DocumentBuilder builder = dBF.newDocumentBuilder();
          // builder.setErrorHandler(new MyErrorHandler());
          InputSource is = new InputSource(file.getAbsolutePath());
          Document doc = builder.parse(is);
          System.out.println(file.getName() + " is well-formed!");
        }
        catch (Exception e) {
          System.out.println(file.getName() + " isn't well-formed!");
          e.printStackTrace();
          System.exit(1);
        }
      }
      else{
        System.out.print("File not found!");
      }
    }
    catch(Exception io){
      io.printStackTrace();
    }
  }
}